package ace.module.account.core.autoconfig;

import ace.cmp.spring.data.jdbc.querydsl.core.QuerydslJdbcRepositoryExtendFactoryBean;
import ace.module.account.core.impl.AccountCoreBootstrapScanner;
import ace.module.account.core.impl.dao.repository.IamAccountRepository;
import ace.module.account.core.impl.properties.AccountCoreProperties;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;

/**
 * boostrap auto config.
 *
 * @author Caspar
 */
@EnableConfigurationProperties({AccountCoreProperties.class})
@ComponentScan(basePackageClasses = {AccountCoreBootstrapScanner.class})
@EnableJdbcRepositories(
    basePackageClasses = {IamAccountRepository.class},
    repositoryFactoryBeanClass = QuerydslJdbcRepositoryExtendFactoryBean.class)
@Configuration
public class AccountCoreAutoConfig {

  @Bean
  public GroupedOpenApi accountGroupedOpenApi() {
    return GroupedOpenApi.builder()
        .group("account")
        .displayName("账户服务")
        .packagesToScan(AccountCoreBootstrapScanner.class.getPackageName())
        .build();
  }
}
